import WorkLjfsSev from '@/api/work-manage/WorkLjfsSev'
import { WORK_TABLE_URL } from '@/utils/const/bizConst'
import { PAGESIZE } from '@/config/AppConstConfig'
export default {
  data() {
    return {
      // table 数据项
      dataRows: [],
      // 点击操作选中的数据
      activeData: {},
      // 总记录数
      total: 0,
      queryObj: {},
      // 表格 loading
      tableLoading: false,
      // 是否展示右侧面板
      isHandlePanel: false,
      page: {
        pageNo: 1,
        pageSize: PAGESIZE
      }
    }
  },
  computed: {
    slotDataCols() {
      return WORK_TABLE_URL.filter(v => v.value === this.$options.name)[0].slotDataCols
    }
  },
  methods: {
    onQueryObjFn(query) {
      this.fetchTableList(query)
    },
    async fetchTableList(query) {
      this.tableLoading = true
      const { data } = await WorkLjfsSev.list(this.$options.name, Object.assign(this.page, query))
      this.dataRows = data.rows.reduce((acc, v) => {
        acc.push(Object.assign(v, v.superviseDocumentData))
        delete v.superviseDocumentData
        return acc
      }, [])
      this.total = data.total
      this.tableLoading = false
    }
  }
}
